﻿using HModel;
using System.Windows.Forms;

namespace HMaker.Controls
{
    /// <summary>
    /// 用于显示图片的列表组件
    /// </summary>
    public class ImgListView : CommonListBox<ImgEntity>
    {
        /// <summary>
        /// 图片键
        /// </summary>
        public string ImgKey { get; set; }

        private void InitSubItems(ListViewItem lvi)
        {
            lvi.SubItems.Clear();
            lvi.SubItems.Add(new ListViewItem.ListViewSubItem());
            lvi.SubItems.Add(new ListViewItem.ListViewSubItem());
        }

        protected override void InitList()
        {
            Columns.Add(new ColumnHeader("图片名称"));
            Columns.Add(new ColumnHeader("基准点偏移"));
        }

        protected override ListViewItem RenderItem(ListViewItem lvi, ImgEntity obj)
        {
            if (lvi.SubItems.Count != 2)
            {
                InitSubItems(lvi);
            }
            lvi.ImageKey = ImgKey;
            lvi.SubItems[0].Text = obj.Name;
            lvi.SubItems[1].Text = obj.BaseOffsetStr;
            return lvi;
        }


    }
}
